package javagame;

import gameobjects.*;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;

public class FinalScene extends BasicGameState {
	
	private Image slika;
	private Image princess;
	private Image prince;
	private Animation help;
	private Animation tenk;
	private int[] duration;
	private Igrac tenkIgrac;
	private float x;
	private float y;

	public FinalScene (int state) {}
	
	public int getID() {
		return 15;
	}
	
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException {
		slika = new Image("res/final_scene.png");
		princess = new Image("res/final_female.png");
		prince = new Image("res/final_male.png");
		tenkIgrac = Igrac.dohvIgraca();
		duration = new int[2];
		duration[0] = duration[1] = 700;
		Image [] h = {new Image("res/help1.png"), new Image("res/help2.png")};
		help = new Animation (h, duration, true);
		x = 487;
		y = 718;
	}
	
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
		slika.draw(0, 0);
		if (tenkIgrac.isMen()) {
			princess.draw(487, 160);
		}
		else {
			prince.draw(487, 160);
		}
		help.draw(462, 115);
		tenk.draw(x, y);
	}
	
	public void fullScreenOnOff (GameContainer gc) throws SlickException {
		if (gc.getInput().isKeyDown(Input.KEY_F)) {
			if (gc.isFullscreen()) {
				gc.setFullscreen(false);
			}
			else {
				gc.setFullscreen(true);
			}
		}
	}
	
	public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException {
		fullScreenOnOff(gc);
		tenk = tenkIgrac.getMovingUp();
		tenk.setAutoUpdate(true);
		y -= Level.constDelta * .1f * 1.5f;
		if (y < 210) {
			y = 718;
			tenk.setAutoUpdate(false);
			sbg.enterState(16);
		}
	}

}
